<template>
	<view class="exam-content">
		<view class="exam-contents" v-for="item in list" :key="item.sort">
			<view class="exam-title">
				<text>{{ item.sort }} {{type[item.type]}}</text>
			</view>
			<view class="exam-subject" v-for="(subject,index) in item.list" :key="subject.id">
				<view class="exam-subject-title">
					{{index + 1}}.{{subject.question}}
				</view>

				<u-radio-group v-model="subject.radio" v-if="item.type === 1">
					<u-radio @change="radioChange" v-for="(opt,index) in subject.options" :key="index"
						:name="opt.description" :disabled="item.disabled" :label=" opt.option + ':' +opt.description">
					</u-radio>
				</u-radio-group>

				<u-checkbox-group v-if="item.type === 2">
					<u-checkbox v-model="checked" v-for="(opt,index) in subject.options" shape="circle"
						:label="opt.option + ':' +opt.description">
					</u-checkbox>
				</u-checkbox-group>

				<u-radio-group v-model="subject.radio" v-if="item.type === 3">
					<u-radio :name="1">正确</u-radio>
					<u-radio :name="0">错误</u-radio>
					<!-- 	<u-radio @change="radioChange" v-for="(opt,index) in subject.options" :key="index"
						:name="opt.description" :disabled="item.disabled">
						{{ opt.option }}:{{ opt.description }}
					</u-radio> -->
				</u-radio-group>




			</view>
		</view>
		<u-empty mode="data" icon="http://cdn.uviewui.com/uview/empty/data.png" text='暂无数据'
			v-if="!list.length"></u-empty>
		<view class="exam-foot" v-if="list.length">
			<u-button type="primary" text="提交" shape="circle" @click="submit"></u-button>
		</view>

	</view>
</template>

<script>
	import {
		api_getexamlist
	} from '@/api/examcontent.js'
	export default {
		data() {
			return {
				checked: [],
				list: [],
				options: {},

				type: {
					1: '单选题',
					2: '多选题',
					3: '判断题',
					4: '填空题'
				}
			}
		},

		onLoad(options) {
			this.options = options;
			this.query();
		},
		mounted() {

		},
		methods: {
			async query() {
				uni.showLoading({
					title: "数据加载中...",
					mask: true, // 是否显示透明蒙层，防止触摸穿透
				});
				let res = await api_getexamlist(this.options);
				if (res.code === 1) {
					this.list = res.data.list;
				} else {
					uni.showToast({
						title: result.msg,
						icon: 'error'
					});
				}
				uni.hideLoading();
			},
			
		    async submit(){
				// let res = await 
				let app = this;
				
				let msg = (list)=>{
					return '请全部填写完后提交'
				}
				
				
				
			}









		}
	}
</script>




<style lang="scss" scoped>
	.exam-content {
		padding-bottom: 50px;

		// padding: 20rpx;
		.exam-contents {
			padding: 20rpx;

		}

		.exam-title {
			padding: 20rpx 0;
			font-size: 34rpx;
			font-weight: 600;
		}

		.exam-subject {
			padding: 10rpx 0;
			font-size: 30rpx;

			.exam-subject-title {
				padding: 10rpx 0;
			}

			.u-radio {
				padding: 0 10rpx;

			}

			.u-checkbox {
				padding: 0 10rpx;

			}
		}
	}

	.exam-foot {
		position: fixed;
		width: 100%;
		bottom: 0;
	}
</style>